package com.fengye.algorithms.leecode;

/**
 * @Author fengye
 * @Date 2023/4/10 9:39
 **/
public class AverageSalary1491 {
    public double average(int[] salary) {
        int min = salary[0];
        int max = salary[0];
        for(int i=1;i<salary.length;i++) {
            if(salary[i] < min) {
                min = salary[i];
            }
            if(salary[i] > max) {
                max = salary[i];
            }
        }

        double all = 0;
        for(int i=0;i<salary.length;i++) {
            if(salary[i] != min && salary[i] != max) {
                all += salary[i];
            }
        }

        return all / (salary.length-2);
    }
}
